#include<bits/stdc++.h>
using namespace std;
int main(){
	int m,n;
	cin >> n >> m;
	vector<set<char> > right(m);
	vector<int> score(m),wrong(m);
	int temp;
	for(int i = 0;i < m;i++){
		int k;
		cin >> score[i] >> temp >> k;
		for(int j = 0;j < k;j++){
			char ch;
			scanf(" %c",&ch);
			right[i].insert(ch);
		}
	}
	for(int i = 0;i < n;i++){
		int sum = 0;
		scanf("\n");
		for(int j = 0;j < m;j++){
			int k;
			set<char> choice;
			if(j!=0) scanf(" ");
			scanf("(%d",&k);
			for(int l = 0;l < k;l++){
				char ch;
				scanf(" %c",&ch);
				choice.insert(ch);
			}
			if(choice==right[j]) sum += score[j];
			else wrong[j]++;
			scanf(")");
		}
		cout << sum << endl;
	}
	int max = 0;
	for(int i = 0;i < m;i++){
		if(wrong[i]>max) max = wrong[i];
	}
	if(!max) cout << "Too simple";
	else{
		cout << max;
		for(int i = 0;i < m;i++){
			if(wrong[i]==max) cout << " " << i+1;
		}
	}
	return 0;
}
